]> git.r.bdr.sh - rbdr/super-polarity/blobdiff - Super Polarity/Actors/Bullet.cs
Protoshow sprint.
[rbdr/super-polarity] / Super Polarity / Actors / Bullet.cs
index 6862e69ca47891a8df9c6b27367deacef0597ac6..d20289cd536aa832ac8a1e7d5ff2764877474c87 100644 (file)
@@ -10,8 +10,9 @@ namespace SuperPolarity
     class Bullet : Actor
     {
         protected ParticleEngine particleEngine;
+        public int Power;
 
-        public Bullet(Game newGame)
+        public Bullet(SuperPolarity newGame)
             : base(newGame)
         {
         }
@@ -24,6 +25,12 @@ namespace SuperPolarity
         public override void Initialize(Texture2D texture, Vector2 position)
         {
             base.Initialize(texture, position);
+            BoxDimensions.X = 10;
+            BoxDimensions.Y = 10;
+            BoxDimensions.W = 10;
+            BoxDimensions.Z = 10;
+            MaxVelocity = 8;
+            InitBox();
             particleEngine = ParticleEffectFactory.CreateBullet(position);
         }
 
@@ -32,7 +39,10 @@ namespace SuperPolarity
             Velocity.X = (float)(MaxVelocity * Math.Cos(Angle));
             Velocity.Y = (float)(MaxVelocity * Math.Sin(Angle));
 
+            Power = 1;
+
             Position += Velocity;
+            UpdateBox();
 
             particleEngine.Update();
             particleEngine.EmitterLocation = Position;
@@ -43,5 +53,28 @@ namespace SuperPolarity
             base.Draw(spriteBatch);
             particleEngine.Draw(spriteBatch);
         }
+
+        public override void Collide(Actor other, Rectangle collision)
+        {
+            if (Dying) { return; }
+            if (other.GetType().IsAssignableFrom(typeof(StandardShip)))
+            {
+                Die();
+                return;
+            }
+        }
+
+        protected override void Die()
+        {
+            ActorManager.CheckOut(this);
+            Renderer.CheckOut(this);
+            Parent.Children.Remove(this);
+        }
+
+        public override void CleanUp()
+        {
+            base.CleanUp();
+            this.particleEngine = null;
+        }
     }
 }